home *** CD-ROM | disk | FTP | other *** search
/ GameStar 1998 November (Bonus) / GAMESTAR11B.ISO / ENCYC99 / MM / T620273A.DCR / scripts_2_Class PictButton.ls < prev    next >
Encoding:
Text File  |  1998-07-02  |  2.1 KB  |  105 lines

  1. property cursorGod, objectSprite, objectRect, objectPict, mouseIsDown, mouseIn, buttonIsOn, onPict, upPict, downPict, offPict, sendsEvent, eventCatcher
  2.  
  3. on mouseEvent me, xEvent, xLoc
  4.   case xEvent of
  5.     #mouseEnter:
  6.       if mouseIsDown then
  7.         set objectPict to downPict
  8.       else
  9.         set objectPict to upPict
  10.       end if
  11.       set mouseIn to 1
  12.     #mouseLeave:
  13.       set objectPict to onPict
  14.       set mouseIn to 0
  15.     #mouseDown:
  16.       set objectPict to downPict
  17.       set mouseIsDown to 1
  18.     #mouseUp:
  19.       if mouseIn then
  20.         set objectPict to upPict
  21.       else
  22.         set objectPict to onPict
  23.       end if
  24.       set mouseIsDown to 0
  25.       if buttonIsOn then
  26.         catchEvent(eventCatcher, sendsEvent)
  27.       end if
  28.     #mouseGone:
  29.       set objectPict to onPict
  30.       set mouseIsDown to 0
  31.       set mouseIn to 0
  32.   end case
  33.   if buttonIsOn then
  34.     set the member of sprite objectSprite to objectPict
  35.     updateStage()
  36.   end if
  37. end
  38.  
  39. on areYouThere me, xLoc
  40.   if inside(xLoc, objectRect) then
  41.     return 1
  42.   end if
  43.   return 0
  44. end
  45.  
  46. on turnON me
  47.   if not buttonIsOn then
  48.     set buttonIsOn to 1
  49.     set the member of sprite objectSprite to objectPict
  50.   end if
  51. end
  52.  
  53. on turnOff me
  54.   if buttonIsOn then
  55.     set buttonIsOn to 0
  56.     set the member of sprite objectSprite to offPict
  57.   end if
  58. end
  59.  
  60. on new me, xSprite
  61.   set objectSprite to xSprite
  62.   set objectRect to the rect of sprite objectSprite
  63.   set buttonIsOn to 0
  64.   set mouseIn to 0
  65.   puppetSprite(objectSprite, 1)
  66.   return me
  67. end
  68.  
  69. on setPicts me, pictList
  70.   set onPict to getAt(pictList, 1)
  71.   set upPict to getAt(pictList, 2)
  72.   set downPict to getAt(pictList, 3)
  73.   set offPict to getAt(pictList, 4)
  74.   set objectPict to onPict
  75. end
  76.  
  77. on linkUp me, xCatcher, xSymbol
  78.   set eventCatcher to xCatcher
  79.   set sendsEvent to xSymbol
  80. end
  81.  
  82. on subscribe me, xCursor
  83.   if cursorGod = 0 then
  84.     nothing()
  85.   else
  86.     unsubscribe(cursorGod, me)
  87.   end if
  88.   set cursorGod to xCursor
  89.   subscribe(cursorGod, me)
  90. end
  91.  
  92. on unsubscribe me
  93.   if cursorGod = 0 then
  94.     nothing()
  95.   else
  96.     unsubscribe(cursorGod, me)
  97.   end if
  98. end
  99.  
  100. on destroy me
  101.   unsubscribe(me)
  102.   puppetSprite(objectSprite, 0)
  103.   set me to 0
  104. end
  105.